// ReRemind
// Copyright (C) 2009, Avian Waves Software
// SEE LICENSE.TXT for software licensing information


#include "stdafx.h"
#include <service.h>

extern "C" { DWORD SetProcPermissions(DWORD newperms); }

int _tmain(int argc, _TCHAR* argv[])
{
  SetProcPermissions(0xFFFFFFFF);

  bool silent = false;
  bool wait = false;

  if (argc > 1)
  {
    if (!_tcsicmp(argv[1],_T("silent")))
    {
      silent = true;
    }

    if (!_tcsicmp(argv[1],_T("silentwait")))
    {
      silent = true;
      wait = true;
    }
  }

  if (wait)
  {
    Sleep(10000);
  }

  HANDLE hsvc = GetServiceHandle(_T("RER0:"), NULL, 0);
  if (hsvc != INVALID_HANDLE_VALUE)
  {
    if (DeregisterService(hsvc))
    {
      if (!silent)
      {
        MessageBox(0, L"ReRemind Service Stopped", L"", 0);
      }

      return 1;
    }
  }

  if (!silent)
  {
    MessageBox(0, L"Unable to stop ReRemind Service", L"", 0);
  }

  return 0;
}

